<!--
 * @Descripttion: 
 * @Version: 
 * @Author: gaohj
 * @Date: 2023-01-11 10:12:05
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2023-01-11 10:14:38
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            width: 5000px;
            height: 5000px;
        }
    </style>
</head>
<body>
    <script>
        window.onscroll = function(){
            // 高度
            // var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
            // console.log(scrollTop);

            // 宽度
            var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
            console.log(scrollLeft);
        }
    </script>
</body>
</html>